 /**
 * @file tal_endpoint_register.h
 * @brief Common process - endpoint register
 * @version 1.0.0
 * @date 2021-09-08
 *
 * @copyright Copyright 2018-2021 Tuya Inc. All Rights Reserved.
 *
 */

#ifndef __TAL_ENDPOINT_REGISTER_H__
#define __TAL_ENDPOINT_REGISTER_H__


#ifdef __cplusplus
    extern "C" {
#endif

#include "tuya_cloud_types.h"
#include "tuya_zigbee_stack.h"


/* 
 * attribute instantiation structure 
*/
typedef struct {
    UINT16_T        attr_id;    ///< attributes id
    ZG_ATTR_TYPE_E  type;       ///< attributes data type
    UINT8_T         size;       ///< length of attributes value
    UINT8_T         mask;       ///< attributes mask
    UINT8_T         flag;       ///< indicates whether ATT supports the scene
    VOID_T          *value;     ///< the default value of attribute
} TAL_ATTR_T;

/* 
 * cluster instantiation structure 
*/
typedef struct {
    UINT16_T    cluster_id;     ///< cluster id, see ZG_CLUSTER_ID_E
    TAL_ATTR_T  *attr_list;     ///< a list of attributes definitions
    UINT8_T     attr_sums;      ///< how many attributes does a cluster have
} TAL_CLUSTER_T;

/*
 * Zigbee cluster triplet structure
*/
typedef struct {
    UINT8_T  ep_id;             ///< endpoint id
    UINT8_T  is_server;         ///< cluster is server or client
    UINT16_T cluster_id;        ///< cluster id,see ZG_CLUSTER_ID_E
} TAL_CLUSTER_TRIPLET_T;

/* 
 * endpoint instantiation structure 
*/
typedef struct {
    UINT8_T         ep_id;                  ///< endpoint id
    ZG_PROFILE_ID_E profile;                ///< profile of endpoint
    ZG_DEV_ID_E     dev_id;                 ///< device id of endpoint
    UINT8_T         server_cluster_sums;    ///< the number of clusters on the server side
    TAL_CLUSTER_T   *server_cluster_list;   ///< server cluster
    UINT8_T         client_cluster_sums;    ///< the number of clusters on the client side
    TAL_CLUSTER_T   *client_cluster_list;   ///< client cluster
} TAL_ENDPOINT_T;


/**
 * @brief get the total number of endpoints
 *
 * @param[in] none
 * @return endpoint number
 */
UINT8_T tal_zg_endpoint_count_get(VOID_T);

/**
 * @brief the endpoint used by the dynamically registered application layer 
 * can only be called once during initialization.
 *
 * @param[in] ep_desc: point to endpoint list
 * @param[in] sums:    endpoint number
 * @return  0: success  Other: fail
 */
OPERATE_RET tal_zg_endpoint_register(TAL_ENDPOINT_T *ep_desc, UINT8_T sums);



#ifdef __cplusplus
}
#endif

#endif

